package sis.ui;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-08-05 17:58
 * @notify
 * @version 1.0
 */

import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;

//过滤器
public class UpcaseFilter extends DocumentFilter {
    public void insertString(
            DocumentFilter.FilterBypass bypass,
            int offset, String text, AttributeSet attr) throws BadLocationException {
        //大写转小写
        bypass.insertString(offset, text.toUpperCase(), attr);
    }

    public void replace(
            DocumentFilter.FilterBypass bypass,
            int offset, int length, String text, AttributeSet attr) throws BadLocationException {
        //大写转小写
        bypass.replace(offset, length, text.toUpperCase(), attr);
    }
}
